home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / c++ / sbuf.pub.z / sbuf.pub
Encoding:
Text File  |  1998-10-30  |  20.0 KB  |  265 lines

  1.  
  2.  
  3.  
  4. SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))                                                  SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      streambuf - public interface of character buffering class
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_iiii_oooo_ssss_tttt_rrrr_eeee_aaaa_mmmm_...._hhhh_>>>>
  13.  
  14.      _tttt_yyyy_pppp_eeee_dddd_eeee_ffff _llll_oooo_nnnn_gggg _ssss_tttt_rrrr_eeee_aaaa_mmmm_oooo_ffff_ffff_,,,, _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss_;;;;
  15.      _cccc_llll_aaaa_ssss_ssss _iiii_oooo_ssss _{{{{
  16.      _pppp_uuuu_bbbb_llll_iiii_cccc_::::
  17.                _eeee_nnnn_uuuu_mmmm      _ssss_eeee_eeee_kkkk______dddd_iiii_rrrr _{{{{ _bbbb_eeee_gggg_,,,, _cccc_uuuu_rrrr_,,,, _eeee_nnnn_dddd _}}}}_;;;;
  18.                _eeee_nnnn_uuuu_mmmm      _oooo_pppp_eeee_nnnn______mmmm_oooo_dddd_eeee _{{{{ _iiii_nnnn_,,,, _oooo_uuuu_tttt_,,,, _aaaa_tttt_eeee_,,,, _aaaa_pppp_pppp_,,,, _tttt_rrrr_uuuu_nnnn_cccc_,,,, _nnnn_oooo_cccc_rrrr_eeee_aaaa_tttt_eeee_,,,, _nnnn_oooo_rrrr_eeee_pppp_llll_aaaa_cccc_eeee _}}}} _;;;;
  19.                _////_//// _aaaa_nnnn_dddd _llll_oooo_tttt_ssss _oooo_ffff _oooo_tttt_hhhh_eeee_rrrr _ssss_tttt_uuuu_ffff_ffff _...._...._.... _SSSS_eeee_eeee _iiii_oooo_ssss_((((_3333_CCCC_++++_++++_))))
  20.      _}}}} _;;;;
  21.  
  22.      _cccc_llll_aaaa_ssss_ssss _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff _{{{{
  23.      _pppp_uuuu_bbbb_llll_iiii_cccc _::::
  24.  
  25.                _iiii_nnnn_tttt       _iiii_nnnn______aaaa_vvvv_aaaa_iiii_llll_((((_))))_;;;;
  26.                _iiii_nnnn_tttt       _oooo_uuuu_tttt______wwww_aaaa_iiii_tttt_iiii_nnnn_gggg_((((_))))_;;;;
  27.                _iiii_nnnn_tttt       _ssss_bbbb_uuuu_mmmm_pppp_cccc_((((_))))_;;;;
  28.                _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff_****_ssss_eeee_tttt_bbbb_uuuu_ffff_((((_cccc_hhhh_aaaa_rrrr_**** _pppp_tttt_rrrr_,,,, _iiii_nnnn_tttt _llll_eeee_nnnn_))))_;;;;
  29.                _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss _ssss_eeee_eeee_kkkk_pppp_oooo_ssss_((((_ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss_,,,, _iiii_nnnn_tttt _====_iiii_oooo_ssss_::::_::::_iiii_nnnn_||||_iiii_oooo_ssss_::::_::::_oooo_uuuu_tttt_))))_;;;;
  30.                _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss _ssss_eeee_eeee_kkkk_oooo_ffff_ffff_((((_ssss_tttt_rrrr_eeee_aaaa_mmmm_oooo_ffff_ffff_,,,, _ssss_eeee_eeee_kkkk______dddd_iiii_rrrr_,,,, _iiii_nnnn_tttt _====_iiii_oooo_ssss_::::_::::_iiii_nnnn_||||_iiii_oooo_ssss_::::_::::_oooo_uuuu_tttt_))))_;;;;
  31.                _iiii_nnnn_tttt       _ssss_gggg_eeee_tttt_cccc_((((_))))_;;;;
  32.                _iiii_nnnn_tttt       _ssss_gggg_eeee_tttt_nnnn_((((_cccc_hhhh_aaaa_rrrr_**** _pppp_tttt_rrrr_,,,, _iiii_nnnn_tttt _nnnn_))))_;;;;
  33.                _iiii_nnnn_tttt       _ssss_nnnn_eeee_xxxx_tttt_cccc_((((_))))_;;;;
  34.                _iiii_nnnn_tttt       _ssss_pppp_uuuu_tttt_bbbb_aaaa_cccc_kkkk_cccc_((((_cccc_hhhh_aaaa_rrrr_))))_;;;;
  35.                _iiii_nnnn_tttt       _ssss_pppp_uuuu_tttt_cccc_((((_iiii_nnnn_tttt _cccc_))))_;;;;
  36.                _iiii_nnnn_tttt       _ssss_pppp_uuuu_tttt_nnnn_((((_cccc_oooo_nnnn_ssss_tttt _cccc_hhhh_aaaa_rrrr_**** _ssss_,,,, _iiii_nnnn_tttt _nnnn_))))_;;;;
  37.                _vvvv_oooo_iiii_dddd      _ssss_tttt_oooo_ssss_ssss_cccc_((((_))))_;;;;
  38.                _vvvv_iiii_rrrr_tttt_uuuu_aaaa_llll _iiii_nnnn_tttt_ssss_yyyy_nnnn_cccc_((((_))))_;;;;
  39.      _}}}}_;;;;
  40.  
  41. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  42.      The _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff class supports buffers into which characters can be
  43.      inserted (put) or from which characters can be fetched (gotten).
  44.      Abstractly, such a buffer is a sequence of characters together with one
  45.      or two pointers (a get and/or a put pointer) that define the location at
  46.      which characters are to be inserted or fetched.  The pointers should be
  47.      thought of as pointing between characters rather than at them.  This
  48.      makes it easier to understand the boundary conditions (a pointer before
  49.      the first character or after the last).  Some of the effects of getting
  50.      and putting are defined by this class but most of the details are left to
  51.      specialized classes derived from _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff.  (See _ffff_iiii_llll_eeee_bbbb_uuuu_ffff(3C++),
  52.      _ssss_ssss_bbbb_uuuu_ffff(3C++), and _ssss_tttt_dddd_iiii_oooo_bbbb_uuuu_ffff(3C++).)
  53.  
  54.      Classes derived from _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff vary in their treatments of the get and
  55.      put pointers.  The simplest are unidirectional buffers which permit only
  56.      gets or only puts.  Such classes serve as pure sources (producers) or
  57.      sinks (consumers) of characters.  Queuelike buffers (e.g., see
  58.      _ssss_tttt_rrrr_ssss_tttt_rrrr_eeee_aaaa_mmmm(3C++) and _ssss_ssss_bbbb_uuuu_ffff(3C++)) have a put and a get pointer which move
  59.      independently of each other.  In such buffers characters that are stored
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))                                                  SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      are held (i.e., queued) until they are later fetched.  Filelike buffers
  75.      (e.g., _ffff_iiii_llll_eeee_bbbb_uuuu_ffff, see _ffff_iiii_llll_eeee_bbbb_uuuu_ffff(3C++)) permit both gets and puts but have
  76.      only a single pointer.  (An alternative description is that the get and
  77.      put pointers are tied together so that when one moves so does the other.)
  78.  
  79.      Most _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff member functions are organized into two phases.  As far as
  80.      possible, operations are performed inline by storing into or fetching
  81.      from arrays (the _g_e_t _a_r_e_a and the _p_u_t _a_r_e_a, which together form the
  82.      _r_e_s_e_r_v_e _a_r_e_a, or _b_u_f_f_e_r).  From time to time, virtual functions are
  83.      called to deal with collections of characters in the get and put areas.
  84.      That is, the virtual functions are called to fetch more characters from
  85.      the ultimate producer or to flush a collection of characters to the
  86.      ultimate consumer.  Generally the user of a _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff does not have to
  87.      know anything about these details, but some of the public members pass
  88.      back information about the state of the areas.  Further detail about
  89.      these areas is provided in _ssss_bbbb_uuuu_ffff_...._pppp_rrrr_oooo_tttt(3C++), which describes the protected
  90.      interface.
  91.  
  92.      The public member functions of the _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff class are described below.
  93.      In the following descriptions assume:
  94.      - _i, _n, and _l_e_n are _iiii_nnnn_tttts.
  95.      - _c is an _iiii_nnnn_tttt. It always holds a ``character'' value or _EEEE_OOOO_FFFF.  A
  96.      ``character'' value is always positive even when _cccc_hhhh_aaaa_rrrr is normally sign
  97.      extended.
  98.      - _s_b and _s_b_1 are _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff_****s.
  99.      - _p_t_r is a _cccc_hhhh_aaaa_rrrr_****.
  100.      - _o_f_f is a _ssss_tttt_rrrr_eeee_aaaa_mmmm_oooo_ffff_ffff.
  101.      - _p_o_s is a _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss.
  102.      - _d_i_r is a _ssss_eeee_eeee_kkkk______dddd_iiii_rrrr.
  103.      - _m_o_d_e is an _iiii_nnnn_tttt representing an _oooo_pppp_eeee_nnnn______mmmm_oooo_dddd_eeee.
  104.  
  105.      Public member functions:
  106.  
  107.      _i_====_s_b_----_>>>>_iiii_nnnn______aaaa_vvvv_aaaa_iiii_llll_((((_))))
  108.           Returns the number of characters that are immediately available in
  109.           the get area for fetching.  _i characters may be fetched with a
  110.           guarantee that no errors will be reported.
  111.  
  112.      _i_====_s_b_----_>>>>_oooo_uuuu_tttt______wwww_aaaa_iiii_tttt_iiii_nnnn_gggg_((((_))))
  113.           Returns the number of characters in the put area that have not been
  114.           consumed (by the ultimate consumer).
  115.  
  116.      _c_====_s_b_----_>>>>_ssss_bbbb_uuuu_mmmm_pppp_cccc_((((_))))
  117.           Moves the get pointer forward one character and returns the
  118.           character it moved past.  Returns _EEEE_OOOO_FFFF if the get pointer is
  119.           currently at the end of the sequence.
  120.  
  121.      _p_o_s_====_s_b_----_>>>>_ssss_eeee_eeee_kkkk_oooo_ffff_ffff_((((_o_f_f_,,,, _d_i_r_,,,, _m_o_d_e_))))
  122.           Repositions the get and/or put pointers.  _m_o_d_e specifies whether the
  123.           put pointer (_iiii_oooo_ssss_::::_::::_oooo_uuuu_tttt bit set) or the get pointer (_iiii_oooo_ssss_::::_::::_iiii_nnnn bit set)
  124.           is to be modified.  Both bits may be set in which case both pointers
  125.           should be affected.  _o_f_f is interpreted as a byte offset.  (Notice
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))                                                  SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.           that it is a signed quantity.)  The meanings of possible values of
  141.           _d_i_r are
  142.  
  143.           _iiii_oooo_ssss_::::_::::_bbbb_eeee_gggg
  144.                The beginning of the stream.
  145.  
  146.           _iiii_oooo_ssss_::::_::::_cccc_uuuu_rrrr
  147.                The current position.
  148.  
  149.           _iiii_oooo_ssss_::::_::::_eeee_nnnn_dddd
  150.                The end of the stream (end of file.)
  151.  
  152.      Not all classes derived from _ssss_tttt_rrrr_eeee_aaaa_mmmm_bbbb_uuuu_ffff support repositioning.  _ssss_eeee_eeee_kkkk_oooo_ffff_ffff_((((_))))
  153.      will return _EEEE_OOOO_FFFF if the class does not support repositioning.  If the
  154.      class does support repositioning, _ssss_eeee_eeee_kkkk_oooo_ffff_ffff_((((_)))) will return the new position
  155.      or _EEEE_OOOO_FFFF on error.
  156.  
  157.      _p_o_s_====_s_b_----_>>>>_ssss_eeee_eeee_kkkk_pppp_oooo_ssss_((((_p_o_s_,,,, _m_o_d_e_))))
  158.           Repositions the streambuf get and/or put pointer to _p_o_s.  _m_o_d_e
  159.           specifies which pointers are affected as for _ssss_eeee_eeee_kkkk_oooo_ffff_ffff_((((_)))).  Returns _p_o_s
  160.           (the argument) or _EEEE_OOOO_FFFF if the class does not support repositioning or
  161.           an error occurs.  In general a _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss should be treated as a
  162.           ``magic cookie'' and no arithmetic should be performed on it.  Two
  163.           particular values have special meaning:
  164.  
  165.           _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss_((((_0000_))))
  166.                The beginning of the file.
  167.  
  168.           _ssss_tttt_rrrr_eeee_aaaa_mmmm_pppp_oooo_ssss_((((_EEEE_OOOO_FFFF_))))
  169.                Used as an error indication.
  170.  
  171.      _c_====_s_b_----_>>>>_ssss_gggg_eeee_tttt_cccc_((((_))))
  172.           Returns the character after the get pointer.  Contrary to what most
  173.           people expect from the name _I_T _D_O_E_S _N_O_T _M_O_V_E _T_H_E _G_E_T _P_O_I_N_T_E_R .
  174.           Returns _EEEE_OOOO_FFFF if there is no character available.
  175.  
  176.      _s_b_1_====_s_b_----_>>>>_ssss_eeee_tttt_bbbb_uuuu_ffff_((((_p_t_r_,,,, _l_e_n_,,,, _i_))))
  177.           Offers the _l_e_n bytes starting at _p_t_r as the reserve area.  If _p_t_r is
  178.           null or _l_e_n is zero or less, then an unbuffered state is requested.
  179.           Whether the offered area is used, or a request for unbuffered state
  180.           is honored depends on details of the derived class.  _ssss_eeee_tttt_bbbb_uuuu_ffff_((((_))))
  181.           normally returns _s_b, but if it does not accept the offer or honor
  182.           the request, it returns 0.
  183.  
  184.      _i_====_s_b_----_>>>>_ssss_gggg_eeee_tttt_nnnn_((((_p_t_r_,,,, _n_))))
  185.           Fetches the _n characters following the get pointer and copies them
  186.           to the area starting at _p_t_r.  When there are fewer than _n characters
  187.           left before the end of the sequence _ssss_gggg_eeee_tttt_nnnn_((((_)))) fetches whatever
  188.           characters remain.  _ssss_gggg_eeee_tttt_nnnn_((((_)))) repositions the get pointer following
  189.           the fetched characters and returns the number of characters fetched.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))                                                  SSSSBBBBUUUUFFFF....PPPPUUUUBBBB((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      _c_====_s_b_----_>>>>_ssss_nnnn_eeee_xxxx_tttt_cccc_((((_))))
  207.           Moves the get pointer forward one character and returns the
  208.           character following the new position.  It returns _EEEE_OOOO_FFFF if the pointer
  209.           is currently at the end of the sequence or is at the end of the
  210.           sequence after moving forward.
  211.  
  212.      _i_====_s_b_----_>>>>_ssss_pppp_uuuu_tttt_bbbb_aaaa_cccc_kkkk_cccc_((((_c_))))
  213.           Moves the get pointer back one character.  _c must be the current
  214.           content of the sequence just before the get pointer.  The underlying
  215.           mechanism may simply back up the get pointer or may rearrange its
  216.           internal data structures so the _c is saved.  Thus the effect of
  217.           _ssss_pppp_uuuu_tttt_bbbb_aaaa_cccc_kkkk_cccc_((((_)))) is undefined if _c is not the character before the get
  218.           pointer.  _ssss_pppp_uuuu_tttt_bbbb_aaaa_cccc_kkkk_cccc_((((_)))) returns _EEEE_OOOO_FFFF when it fails.  The conditions
  219.           under which it can fail depend on the details of the derived class.
  220.  
  221.      _i_====_s_b_----_>>>>_ssss_pppp_uuuu_tttt_cccc_((((_c_))))
  222.           Stores _c after the put pointer, and moves the put pointer past the
  223.           stored character; usually this extends the sequence.  It returns _EEEE_OOOO_FFFF
  224.           when an error occurs.  The conditions that can cause errors depend
  225.           on the derived class.
  226.  
  227.      _i_====_s_b_----_>>>>_ssss_pppp_uuuu_tttt_nnnn_((((_p_t_r_,,,, _n_))))
  228.           Stores the _n characters starting at _p_t_r after the put pointer and
  229.           moves the put pointer past them.  _ssss_pppp_uuuu_tttt_nnnn_((((_)))) returns _i, the number of
  230.           characters stored successfully.  Normally _i is _n, but it may be less
  231.           when errors occur.
  232.  
  233.      _s_b_----_>>>>_ssss_tttt_oooo_ssss_ssss_cccc_((((_))))
  234.           Moves the get pointer forward one character.  If the pointer started
  235.           at the end of the sequence this function has no effect.
  236.  
  237.      _i_====_s_b_----_>>>>_ssss_yyyy_nnnn_cccc_((((_))))
  238.           Establishes consistency between the internal data structures and the
  239.           external source or sink.  The details of this function depend on the
  240.           derived class.  Usually this ``flushes'' any characters that have
  241.           been stored but not yet consumed, and ``gives back'' any characters
  242.           that may have been produced but not yet fetched.  _ssss_yyyy_nnnn_cccc_((((_)))) returns _EEEE_OOOO_FFFF
  243.           to indicate errors.
  244.  
  245. CCCCAAAAVVVVEEEEAAAATTTTSSSS
  246.      _ssss_eeee_tttt_bbbb_uuuu_ffff does not really belong in the public interface. It is there for
  247.      compatibility with the stream package.
  248.  
  249.      Requiring the program to provide the previously fetched character to
  250.      _ssss_pppp_uuuu_tttt_bbbb_aaaa_cccc_kkkk is probably a botch.
  251.  
  252. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  253.      _iiii_oooo_ssss(3C++) _iiii_ssss_tttt_rrrr_eeee_aaaa_mmmm(3C++) _oooo_ssss_tttt_rrrr_eeee_aaaa_mmmm(3C++), _ssss_bbbb_uuuu_ffff_...._pppp_rrrr_oooo_tttt(3C++)
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.